var userDb = require('./userDatabaseHandler');
var stdError = require('./standardErrors');

function getAuthenticatedUser(req, res) {
	if (req.session.token != null) {
		var user = userDb.getUserById(req.session.token);
		if (user != null) {
			return user;
		}
	}
	stdError.error500(res);
	return null;
}

exports.getAuthenticatedUser = getAuthenticatedUser;